package com.ewins.weatherdataclient.https;

import java.net.Authenticator;
import java.net.InetAddress;
import java.net.PasswordAuthentication;

/**
 * Created by hp on 2015/12/10.
 */
public class MyAuthenticator extends Authenticator {
    private String name;
    private String passwd;
    public MyAuthenticator(String name,String passwd){
        this.name = name;
        this.passwd = passwd;
    }

    protected PasswordAuthentication getPasswordAuthentication() {
        String promptString = getRequestingPrompt();
        String hostname = getRequestingHost();
        InetAddress ipaddr = getRequestingSite();
        //int port = getRequestingPort();

        String username = name;
        String password = passwd;
        return new PasswordAuthentication(username, password.toCharArray());
    }
}